package tech.threekilogram.activitytasktest;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class SingleInstanceActivity extends AppCompatActivity implements OnClickListener {

      private static final String TAG = SingleInstanceActivity.class.getSimpleName();

      private TextView mMessage;
      private Button   mStandard;
      private Button   mSingleTop;
      private Button   mSingleTask;
      private Button   mSingleInstance;

      public static void start ( Context context ) {

            Intent starter = new Intent( context, SingleInstanceActivity.class );
            context.startActivity( starter );
      }

      @Override
      protected void onCreate ( Bundle savedInstanceState ) {

            super.onCreate( savedInstanceState );
            setContentView( R.layout.activity_stand );
            initView();

            Log.e( TAG, "onCreate : " + Util.getTask( this ) );
      }

      private void initView ( ) {

            mMessage = findViewById( R.id.message );
            mStandard = findViewById( R.id.standard );
            mSingleTop = findViewById( R.id.singleTop );
            mSingleTask = findViewById( R.id.singleTask );
            mSingleInstance = findViewById( R.id.singleInstance );

            mStandard.setOnClickListener( this );
            mSingleTop.setOnClickListener( this );
            mSingleTask.setOnClickListener( this );
            mSingleInstance.setOnClickListener( this );

            mMessage.setText( "single instance " + Flag.singleInstanceActivityCount );
      }

      @Override
      public void onClick ( View v ) {

            switch( v.getId() ) {
                  case R.id.standard:
                        StandActivity.start( this );
                        break;
                  case R.id.singleTop:
                        SingleTopActivity.start( this );
                        break;
                  case R.id.singleTask:
                        SingleTaskActivity.start( this );
                        break;
                  case R.id.singleInstance:
                        SingleInstanceActivity.start( this );
                        break;
                  default:
                        break;
            }
      }
}
